package Dao;


import Table.Lunbo;
import Utils.DruidUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

public class FindLunBoDao {
    public static ArrayList<Lunbo> Find() {
        Connection conn = null;
        PreparedStatement pstmt = null;
        ResultSet rs = null;
        ArrayList<Lunbo> list = new ArrayList<>();
        try {
            conn = DruidUtils.getConnection();
            String sql = "select * from lunbo ";
            pstmt = conn.prepareStatement(sql);
            rs = pstmt.executeQuery();
            while (rs.next()) {
                Lunbo lunbo = new Lunbo();
                lunbo.setId(rs.getInt("id"));
                lunbo.setAddress(rs.getString("address"));
                list.add(lunbo);
            }

        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } finally {
            DruidUtils.close(rs, pstmt, conn);
        }
        return list;
    }
}
